package cn.xuchunh.campusbbs.storage.sqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import cn.xuchunh.campusbbs.AppContext;

/**
 * Created by XuChunH on 2015/8/31.
 */
public class DBHelper extends SQLiteOpenHelper {
    public static final int VERSION = 2;

    public DBHelper(Context context) {
        super(context, AppContext.getInstance().getUser().getUserId() + "", null, VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DataBaseConstant.CREATE_REPLY_DETAIL);
        db.execSQL(DataBaseConstant.CREATE_LOGINED_USER);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        if (newVersion == 2) {
            db.execSQL(DataBaseConstant.CREATE_LOGINED_USER);
        }
    }
}
